package cn.springcloud.fix.novel.biz.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

@Slf4j
@Service
public class AsyncTest {

    @Async
    public Future<String> ansync(String name) {
        try {
            Thread.sleep(10000);
            log.info("这里是异步方法");
            log.info("传过来的名字是：" + name);
            name = "修改的名字";
            log.info("修改后的名字是：" + name);
            return new AsyncResult<>("name: " + name);
        } catch (Exception e) {
            return new AsyncResult<>("异常");
        }
    }
}
